package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {

    // 1.今日注册、登录
    @Select("select count(distinct user_id) from tb_log where log_time=#{logTime} and type =#{type}")
    Integer countRegAndLog(@Param("logTime") String logTime, @Param("type") String type);

    // 2.今日活跃
    @Select("select count(distinct user_id) from tb_log where log_time=#{logTime}")
    Integer countActvie(String logTime);

    // 3.次日留存
    @Select("select count(distinct user_id) from tb_log where log_time=#{today}" +
            "and user_id in(select distinct user_id from tb_log where log_time=#{yesterday} and type ='0102')")
    Integer countRetention1d(@Param("today") String today, @Param("yesterday") String yesterday);

}